﻿// MIT License
// 开源地址：https://gitee.com/co1024/AbcMvc
// Copyright (c) 2021-2023 1024
// Abc.Mvc=Furion+EF+SqlSugar+Pear layui admin.

using Abc.Utils;
using Furion;

using Microsoft.Extensions.DependencyInjection;

namespace Abc.EntityFramework.Core
{
    [AppStartup(600)]
    public sealed class EntityFrameworkCoreStartup : AppStartup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDatabaseAccessor(options =>
            {
                //获取数据库设置选项
                var dbSettingOptions = AppEx.GetConfig<DbSettingOptions>();

                options.AddDbPool<DefaultDbContext>(dbSettingOptions.DbProvider, optionBuilder: (service, opt) =>
                {
                    //opt.AddInterceptors(serviceProvider.GetRequiredService<SecondLevelCacheInterceptor>());
                });
            }, "Abc.EntityFramework.Migrations");
        }
    }
}